package com.niit.apis;

import com.niit.entity.*;
import com.niit.entity.dto.LoginAccountDTO;
import com.niit.utils.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(name = "user-service")
public interface UserFeignApi {
	@PostMapping("/api/account/login")
	LoginAccountDTO login(
			@RequestParam String phone,
			@RequestParam String password,
			@RequestParam(required = false, defaultValue = "1") Integer loginType
	);

	@PostMapping("/api/account/register")
	Result<Object> register(
			@RequestParam String phone,
			@RequestParam String password,
			@RequestParam(required = false, defaultValue = "1") Integer registerType
	);

	@PostMapping("/api/account/logout")
	Result<Object> logout(@RequestBody LoginAccountDTO loginAccountDTO);

	@GetMapping("/api/menu/getAll")
	List<Menu> getAllMenus();

	@PostMapping("/api/account/getUser/{id}")
	User getUser(@PathVariable Integer id);

	@PostMapping("/api/account/getAdmin/{id}")
	Admin getAdmin(@PathVariable Integer id);

	@PostMapping("/api/region/findRegion")
	List<Region> findRegion(@RequestBody Region region);

	@PostMapping("/api/info/save")
	Info saveInfo(@RequestBody Info info);

	@PostMapping("/api/info/getAll")
	Page<Info> getAllInfos(
			@RequestParam(required = false) String phone,
			@RequestParam(required = false) String username,
			@RequestParam(required = false) String realName,
			@RequestParam(required = false) String gender,
			@RequestParam(defaultValue = "1") Integer page,
			@RequestParam(defaultValue = "10") Integer size
	);

	@PostMapping("/api/info/delete/{id}")
	void deleteInfo(@PathVariable Integer id);

	@GetMapping("/api/region/getRegion/{id}")
	Region getRegion(@PathVariable Long id);

	@PostMapping("/findRegionByLevel")
	List<Region> findRegionByLevel(@RequestParam Byte level);

	@PostMapping("/api/account/updateUser")
	User updateUser(@RequestBody User user);

	@PostMapping("/api/account/deleteUser")
	void deleteUserById(@RequestParam Integer id);

	@PostMapping("/api/company/add")
	Company addCompany(@RequestBody Company company);

	@PostMapping("/api/company/delete/{id}")
	void deleteCompany(@PathVariable Integer id);

	@PostMapping("/api/company/getAll")
	List<Company> getAllCompany();

	@GetMapping("/api/company/list")
	Page<Company> getCompanyList(
			@RequestParam(defaultValue = "1") Integer page,
			@RequestParam(defaultValue = "10") Integer size,
			@RequestParam(required = false) String companyName
	);

	@GetMapping("/api/company/getCompany/{id}")
	Company getCompany(@PathVariable Integer id);

	@PostMapping("/api/account/getAllUser")
	Page<User> getAllUser(
			@RequestParam(required = false) String phone,
			@RequestParam(required = false) String username,
			@RequestParam(required = false) String realName,
			@RequestParam(required = false) String gender,
			@RequestParam(required = false) Boolean userType,
			@RequestParam(defaultValue = "1") int page,
			@RequestParam(defaultValue = "10") int size
	);
}

